package com.aaa.order.controller.api;/**
 * Date:2023/3/3
 * Author：臣哥哥
 * Description:
 */

import com.aaa.entity.AccountOrder;
import com.aaa.entity.CarComment;
import com.aaa.entity.Order;
import com.aaa.order.service.AccountOrderService;
import com.aaa.order.service.CarCommentService;
import com.aaa.order.service.OrderService;
import com.aaa.security.annotation.MyLog;
import com.aaa.vo.AccountOrderVo;
import com.aaa.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author     ：Xiaochen
 * @date       ：Created in 2023/3/3 11:17
 * @description：
 * @modified By：
 * @version:
 */
@Api(value = "/order/member", tags = {"订单控制"})
@RestController
@RequestMapping("/order/member")
public class ApiOrderController {
    @Autowired
    private OrderService orderService;

    @Autowired
    private CarCommentService carCommentService;

    @Autowired
    private AccountOrderService accountOrderService;

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true),
            @ApiImplicitParam(paramType = "body", dataType = "Order", name = "order", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @MyLog(title = "查询所有订单管理")
    @RequestMapping("select")
    public Result list(@RequestParam(defaultValue = "1") Integer currentPage, @RequestParam(defaultValue = "5") Integer pageSize, @RequestBody Order order){
        return orderService.selectAll(currentPage,pageSize,order);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Order", name = "order", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @MyLog(title = "修改订单管理")
    @PostMapping("update")
    public Result update(@RequestBody Order order){
        return orderService.update(order);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "memberId", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "state", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @MyLog(title = "查询客户未支付和已支付还有支付失效的订单")
    @RequestMapping("selectByMemberId")
    public Result selectByMemberId(Integer memberId,Integer state){
        return orderService.selectByMemberId(memberId,state);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "AccountOrderVo", name = "accountOrderVo", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @MyLog(title = "查询客户充值的订单")
    @PostMapping("findByMemberId")
    public Result findByMemberId(@RequestBody AccountOrderVo accountOrderVo){
        return orderService.findByMemberId(accountOrderVo);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "CarComment", name = "carComment", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @MyLog(title = "添加评价")
    @PostMapping("insertCarComment")
    public Result insertCarComment(@RequestBody CarComment carComment){
        return carCommentService.insertCarComment(carComment);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "AccountOrder", name = "accountOrder", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @MyLog(title = "取消充值订单")
    @PostMapping("updateAccountOrder")
    public Result updateAccountOrder(@RequestBody AccountOrder accountOrder){
        System.out.println("accountOrder = " + accountOrder);
        return accountOrderService.update(accountOrder);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Order", name = "order", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @MyLog(title = "添加订单")
    @PostMapping("/insert")
    public Result insert(@RequestBody Order order){
        return orderService.insert(order);
    }

}